package com.ybfenpan.controller.member.member;

import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.model.Member;
import com.ybfenpan.service.MemberService;
import com.ybfenpan.utils.ContextUtil;
import com.ybfenpan.utils.MapUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;


@Controller
 
public class MapFatherController extends BaseController {

	@Resource
	private MemberService memberService;
	 
	@RequestMapping("member/member/tuKuang.shtml")
	public String kuang(ModelMap model, HttpServletRequest request) throws Exception{
		
		
		
		Map formMap = getParameterMap(request);
		//传递的参数
        String loginName = MapUtil.getString(formMap, "loginName");
		 
		Member member1 = null;
		
		Member member21 = null;
		Member member22 = null;
		
		Member member31 = null;
		Member member32 = null;
		Member member33 = null;
		Member member34 = null;
		
		Member member41 = null;
		Member member42 = null;
		Member member43 = null;
		Member member44 = null;
		Member member45 = null;
		Member member46 = null;
		Member member47 = null;
		Member member48 = null;
		
		Member member = ContextUtil.getMember();
		member = this.memberService.getByKey(member.getId());
		if(loginName==null || loginName.length()<1){
			if(member.getLevel()>0){
				member1=this.memberService.getByKey(member.getId());
			}
			
		}else{
			member1=memberService.executMemberByLoginName(loginName);

		}
		
		if(member1!=null){
			//获得第二层
			Integer member21Id=member1.getZuoId();
			member21 = memberService.getByKey(member21Id);
			
			
			Integer member22Id=member1.getYouId();
			member22 = memberService.getByKey(member22Id);
		 
		}
		
		
		//获得第三层
		if(member21!=null){
			
			Integer member31Id=member21.getZuoId();
			member31 = memberService.getByKey(member31Id);
			
			
			Integer member32Id=member21.getYouId();
			member32 = memberService.getByKey(member32Id);
			
		}
		if(member22!=null){
			
			Integer member33Id=member22.getZuoId();
			member33 = memberService.getByKey(member33Id);
			
			
			Integer member34Id=member22.getYouId();
			member34 = memberService.getByKey(member34Id);
			
		}
		
		//获得第四层
		if(member31!=null){
			

			Integer member41Id=member31.getZuoId();
			member41 = memberService.getByKey(member41Id);
			
			
			Integer member42Id=member31.getYouId();
			member42 = memberService.getByKey(member42Id);
			
			
		}
		if(member32!=null){
			
			Integer member43Id=member32.getZuoId();
			member43 = memberService.getByKey(member43Id);
			
			
			Integer member44Id=member32.getYouId();
			member44 = memberService.getByKey(member44Id);
		}
		if(member33!=null){
			
			Integer member45Id=member33.getZuoId();
			member45 = memberService.getByKey(member45Id);
			
			
			Integer member46Id=member33.getYouId();
			member46 = memberService.getByKey(member46Id);
			
		}
		if(member34!=null){
			
			Integer member47Id=member34.getZuoId();
			member47 = memberService.getByKey(member47Id);
			
			
			Integer member48Id=member34.getYouId();
			member48 = memberService.getByKey(member48Id);
		}
		
		request.setAttribute("member1",member1);
		request.setAttribute("member21",member21);
		request.setAttribute("member22",member22);
		request.setAttribute("member31",member31);
		request.setAttribute("member32",member32);
		request.setAttribute("member33",member33);
		request.setAttribute("member34",member34);
		request.setAttribute("member41",member41);
		request.setAttribute("member42",member42);
		request.setAttribute("member43",member43);
		request.setAttribute("member44",member44);
		request.setAttribute("member45",member45);
		request.setAttribute("member46",member46);
		request.setAttribute("member47",member47);
		request.setAttribute("member48",member48);
		
		
		return "member/member/tuKuang";
	}

	

}
